home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
AT.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
85KB
|
2,909 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATKeyboard Version 4.0 ** */
/* ** Copright (C) 1992-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ** Hauptprogramm ** */
/* ** ** */
/* ******************************************************************* */
#include "janus.h"
#include "ATUtilities.h"
#include "Display.h"
extern struct ExecBase *SysBase;
struct JanusBase *JanusBase;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct DiskfontBase *DiskfontBase;
struct Library *MathBase;
struct Library *MathTransBase;
struct Library *RexxSysBase;
struct Library *ExpansionBase;
struct Library *UtilityBase;
struct Library *AslBase;
struct Library *ATUtilitiesBase;
struct Library *TranslatorBase;
struct Device *ConsoleDevice;
extern struct DosLibrary *DOSBase;
extern struct Library *IconBase;
#define MEMSIZE ((sizeof(struct SystemTime)*2)+\
(sizeof(struct Message)*3)+\
100+\
sizeof(struct SHelp)+\
sizeof(struct IOStdReq))
struct AppManager *app;
struct Window *WindowPtr;
struct Window *RegWindow;
struct TextFont *OpalFont;
struct TextFont *SchonerFont;
struct RastPort *RastPortPtr;
struct ServiceData *TimeService;
struct SHelp *SHelp;
struct ATStatus *atstatus;
struct SetupSig *KeyboardInt;
struct Task *MainTask;
struct Task *SubTask;
struct SystemTime *SystemTime;
struct SystemTime *PublicTime;
struct FileHandle *SysTestWindow;
struct FileHandle *NIL;
struct Screen *SchonerScreen;
struct Window *SchonerWindow;
struct RastPort *SchonerRastPort;
struct ViewPort *SchonerViewPort;
struct Task *SchonerTask;
struct Task *ColorCyclingTask;
struct MsgPort *Port1,*Port2,*Port3,*Port4,*Port5;
struct MsgPort *ARexxPort,*ParallelPort;
struct RexxMsg *RexxMsg;
struct Message *Message1,*Message2,*EMessage;
struct Message *AppMessage;
struct TimeServReq *TimeReq;
struct FileRequester *FileRequester;
struct TagItem *FRTags;
struct IOStdReq *ConsoleRequest;
struct IOClipReq *ClipReq;
struct IOExtPar *ParallelRequest;
struct MsgPort *ClipPort;
struct Einstellungen *Prefs;
extern struct WBStartup *WBenchMsg;
extern struct NewScreen SchonerScreenDef;
extern struct NewWindow SchonerWindowDef;
LONG KickstartVersion;
WORD RegTime=-1;
WORD HiFiTime=-1;
LONG KeyboardSignal;
ULONG KeyboardSignalMask;
LONG ServiceSignal;
ULONG ServiceSignalMask;
LONG IntuitionSignal;
ULONG IntuitionSignalMask;
LONG TimerTaskSignal;
ULONG TimerTaskSignalMask;
LONG ARexxSignal;
ULONG ARexxSignalMask;
ULONG AppSignalMask;
ULONG WaitSignalMask;
UBYTE *ATName;
UBYTE *Buffer;
UBYTE *Chip;
UBYTE FPU;
UBYTE CPU;
UBYTE ARexxLock;
UBYTE ARexxMenuLock;
BOOL Online;
BOOL Uhr;
BOOL SystemOK;
BOOL Schoner;
BOOL Service;
BOOL Clock;
BOOL ARexx;
BOOL LPT1;
BOOL Speak;
APTR JanusStart;
LONG ConsoleDev=-1L;
LONG ClipDev=-1L;
struct KStatus
{
UBYTE LShift;
UBYTE RShift;
UBYTE Ctrl;
UBYTE Alt;
} kstatus=
{
0,0,0,0
};
VOID OpenAll();
VOID CloseAll();
VOID Uebertragen();
VOID UebertrageClip();
VOID Fehlerbehandlung();
VOID LadeEinstellungen();
VOID ZeigeEinstellungen();
VOID SichereEinstellungen();
VOID EinstellungenAendern();
VOID Aktiv();
VOID Inaktiv();
VOID TimerTask();
VOID EP();
VOID Auswahl();
VOID KopiereZeit();
VOID KontrolliereUhr();
VOID KontrolliereService();
VOID KontrolliereFPU();
VOID KontrolliereCPU();
VOID LadeTabelle();
VOID Taste();
VOID SetzeTM();
VOID Tastenkombination();
VOID Sendung();
VOID ShowInformation();
VOID FTaste();
VOID LeerePort();
VOID LeereIDCMP();
VOID UhrzeitEinsetzen();
VOID DatumEinsetzen();
VOID NeuerModus();
VOID XLine();
VOID Manager();
VOID Hilfe();
VOID HiFi();
VOID RegCheck();
LONG Abfrage();
UBYTE *StringAbfrage();
UBYTE *FileReq();
BOOL ErstelleTimerTask();
BOOL Requester();
struct Task *CreateProcess();
UBYTE *Wochentage[]={"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag"};
UBYTE *TSRWochentage[]={"Sun","Mon",
"Tue","Wed",
"Thu","Fri",
"Sat"};
UBYTE *Monate[]={"",
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"};
UBYTE *TSRMonate[]={"",
"Jan","Feb","Mar","Apr",
"May","Jun","Jul","Aug",
"Sep","Oct","Nov","Dec"};
UBYTE TastenTabelle[256];
UBYTE FileBuffer[128];
struct KeyCodes *KeyCodes;
UBYTE Druck[]={ 4, 0x60,0x5d,0x5d|BIT7,0x60|BIT7};
UBYTE Break[]={ 4, 0x63,0x5b,0x5b|BIT7,0x63|BIT7};
UBYTE USEin[]={ 6, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE USAus[]={ 6, 0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE Reset[]={ 6, 0x63,0x64,0x46,0x46|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE Setup[]={ 6, 0x63,0x64,0x45,0x45|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE MKAuf[]={16, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7,
0x60,0x1a,0x1a|BIT7,0x60|BIT7,
0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE MKZu[]= {16, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7,
0x60,0x1b,0x1b|BIT7,0x60|BIT7,
0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE IKAuf[]={14, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7,
0x1a,0x1a|BIT7,
0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE IKZu[]= {14, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7,
0x1b,0x1b|BIT7,
0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE Apo[]= {14, 0x63,0x64,0x50,0x50|BIT7,0x64|BIT7,0x63|BIT7,
0x2a,0x2a|BIT7,
0x63,0x64,0x51,0x51|BIT7,0x64|BIT7,0x63|BIT7};
UBYTE PL[]= {4, 0x63,0x45,0x45|BIT7,0x63|BIT7};
UBYTE NE[]= {4, 0x64,0x45,0x45|BIT7,0x64|BIT7};
UBYTE LA[]= {6, 0x60,0x64,0x45,0x45|BIT7,0x64|BIT7,0x60|BIT7};
UBYTE EN[]= {4, 0x64,0x53,0x53|BIT7,0x64|BIT7};
UBYTE TxLad[]={6, 0x45,0x45|BIT7,
0x1a,0x1a|BIT7,
0x28,0x28|BIT7};
UBYTE TxSi[]= {6, 0x45,0x45|BIT7,
0x1a,0x1a|BIT7,
0x21,0x21|BIT7};
UBYTE Lay[]= {6, 0x45,0x45|BIT7,
0x22,0x22|BIT7,
0x28,0x28|BIT7};
UBYTE Drck[]= {6, 0x45,0x45|BIT7,
0x22,0x22|BIT7,
0x22,0x22|BIT7};
#define xITEMENABLED (0xffff-ITEMENABLED)
#define xMENUENABLED (0xffff-MENUENABLED)
#define xCHECKED (0xffff-CHECKED)
/* *********************************************************************
****************** Hauptprogramm ************************************
********************************************************************* */
VOID main(argc,argv)
LONG argc;
UBYTE *argv[];
{
UBYTE SayTModus[44];
UBYTE *name;
ULONG Signale;
ULONG Class;
UWORD Code;
UWORD Qualifier;
UWORD MenuNum,
ItemNum,
SubItemNum;
BOOL bool;
struct IntuiMessage *IMessage;
if(argc!=0)
{
ATName=argv[0];
}
if(argc>=2)
{
printf("\n\n\n%s\n%s\n\n",Copyright[0],Copyright[4]);
LadeEinstellungen(FALSE);
printf(" ARexx-Port: %s\n",ARexxName);
printf(" ARexx-Befehlsübersicht mit\n");
printf(" rx \"address '%s' help\"\n\n",ARexxName);
printf("Weitere Informationen finden Sie\nin der Dokumentationsdatei.\n\n\n");
exit(0);
}
OpenAll();
FOREVER
{
Signale=Wait(WaitSignalMask);
if(Signale & IntuitionSignalMask)
{
IMessage=GetMsg(WindowPtr->UserPort);
if(IMessage!=NULL)
{
do
{
Class=IMessage->Class;
Code=IMessage->Code;
Qualifier=IMessage->Qualifier;
ReplyMsg(IMessage);
switch(Class)
{
case RAWKEY:
if(Online==TRUE)
{
if((Qualifier & IEQUALIFIER_RCOMMAND) ||
(Qualifier & IEQUALIFIER_LCOMMAND))
{
if((Code>=0x50)&&(Code<=0x59))
{
FTaste(Code-0x50,Qualifier);
}
else
{
Taste(Code,Qualifier);
}
}
else
{
Taste(Code,Qualifier);
}
}
break;
case CHANGEWINDOW:
ClearMenuStrip(WindowPtr);
if(WindowPtr->Flags & WFLG_ZOOMED)
{
if(Clock==FALSE)
{
Clock=TRUE;
Einstellungen.Uhr=1;
Aktiv(&Uhr_Item);
}
}
else
{
if(Clock==TRUE)
{
Clock=FALSE;
Einstellungen.Uhr=0;
Inaktiv(&Uhr_Item);
}
}
SetMenuStrip(WindowPtr,&Menu1);
KontrolliereUhr();
break;
case MENUHELP:
if(RegWindow!=NULL)
{
if(RegTime>0)
{
DeleteStdWindow(RegWindow);
RegWindow=NULL;
}
}
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
SubItemNum=SUBNUM(Code);
printf("Menuhelp: %ld %ld %ld\n",MenuNum,ItemNum,SubItemNum);
break;
case MENUPICK:
if(RegWindow!=NULL)
{
if(RegTime>0)
{
DeleteStdWindow(RegWindow);
RegWindow=NULL;
}
}
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
SubItemNum=SUBNUM(Code);
switch(MenuNum)
{
case MENU_DATEI:
switch(ItemNum)
{
case ITEM_EINSTELLUNGEN_LADEN:
Say("reading old preferences");
LadeEinstellungen(TRUE);
ZeigeEinstellungen(TRUE);
break;
case ITEM_EINSTELLUNGEN_SICHERN:
Say("writing new preferences");
SichereEinstellungen();
break;
case ITEM_EINSTELLUNGEN_AENDERN3:
EinstellungenAendern();
switch(SubItemNum)
{
case SUBITEM_A2286:
ClearMenuStrip(WindowPtr);
if(Einstellungen.A2286)
{
Setup_Item.Flags |= ITEMENABLED;
}
else
{
Setup_Item.Flags &= xITEMENABLED;
}
SetMenuStrip(WindowPtr,&Menu1);
break;
case SUBITEM_M68881:
if(Schoner==FALSE)
{
KontrolliereFPU();
}
else
{
ClearMenuStrip(WindowPtr);
if(M68881_Item.Flags & CHECKED) M68881_Item.Flags |= CHECKED; else M68881_Item.Flags &= xCHECKED;
SetMenuStrip(WindowPtr,&Menu1);
}
break;
case SUBITEM_DATACACHE:
case SUBITEM_M68020:
KontrolliereCPU();
break;
case SUBITEM_PRIORITAET:
Einstellungen.Prioritaet=Abfrage("Programmpriorität (-128 bis 127):",
Einstellungen.Prioritaet,-128,127,1);
SetTaskPri(MainTask,Einstellungen.Prioritaet);
break;
}
break;
case ITEM_EINSTELLUNGEN_AENDERN2:
EinstellungenAendern();
switch(SubItemNum)
{
case SUBITEM_TIMESERVICE:
if(Einstellungen.TimeService) Service=TRUE; else Service=FALSE;
KontrolliereService();
break;
case SUBITEM_LPT1:
if(Einstellungen.LPT1Verwaltung) LPT1=TRUE; else LPT1=FALSE;
KontrolliereLPT1();
break;
case SUBITEM_UHR:
if(Einstellungen.Uhr) Clock=TRUE; else Clock=FALSE;
KontrolliereUhr();
break;
case SUBITEM_SPEAK:
if(Einstellungen.Speak) Speak=TRUE; else Speak=FALSE;
Say("narrator turned on");
break;
case SUBITEM_SPEAKPREFS:
NarratorPrefs();
break;
case SUBITEM_AREXX:
ARexxName=StringAbfrage(FALSE,"Neuer Name für den ARexx-Port:",ARexxName);
break;
}
break;
case ITEM_EINSTELLUNGEN_AENDERN1:
EinstellungenAendern();
switch(SubItemNum)
{
case SUBITEM_UEBERTRAGUNGSRATE:
Say("editing keyboard transfer rate");
Einstellungen.Uebertragungsrate=Abfrage("Übertragungsrate in 0.02s:",
Einstellungen.Uebertragungsrate,0,120,1);
break;
}
break;
case ITEM_UEBERTRAGEN:
switch(SubItemNum)
{
case SUBITEM_ASCDATEI:
Say("ascii transfer form a file");
Uebertragen();
break;
case SUBITEM_CLIP:
Say("ascii transfer from the clipboard");
UebertrageClip();
break;
}
break;
case ITEM_ERWEITERUNGEN:
if(Erweiterungen_Item.SubItem!=NULL)
{
CallUtilityList(SubItemNum);
}
break;
case ITEM_MANAGER:
Say("trying to run the utility manager");
Manager();
break;
case ITEM_ENDE:
if(ARexxLock==0) CloseAll(); else DisplayBeep(NULL);
break;
case ITEM_INFORMATION:
if(Schoner==TRUE) WBenchToFront();
Say("showing informations about a t keyboard");
ShowInformation(TRUE);
if(Schoner==TRUE) ScreenToFront(SchonerScreen);
break;
}
break;
case MENU_TASTATUR:
switch(ItemNum)
{
case ITEM_TASTATURMODUS:
if((SubItemNum>=0)&&(SubItemNum<=7))
{
sprintf(&SayTModus,"you have selected keyboard mode number %d\n",SubItemNum);
NeuerModus(SubItemNum,TRUE);
}
else
{
switch(SubItemNum)
{
case SUBITEM_TMEDITOR:
ClearMenuStrip(WindowPtr);
Say("calling the keyboard mode editor");
TMEditor();
SetMenuStrip(WindowPtr,&Menu1);
break;
case SUBITEM_TMONOFF:
ClearMenuStrip(WindowPtr);
TMOnOff();
SetMenuStrip(WindowPtr,&Menu1);
break;
}
}
break;
case ITEM_F:
switch(SubItemNum)
{
case SUBITEM_F_AENDERN:
ClearMenuStrip(WindowPtr);
Say("calling the f key editor");
FTastenAendern();
SetMenuStrip(WindowPtr,&Menu1);
break;
case SUBITEM_F_ZEIGEN:
ClearMenuStrip(WindowPtr);
ZeigeFTasten();
SetMenuStrip(WindowPtr,&Menu1);
break;
}
break;
case ITEM_ONLINE:
XLine(TRUE);
Say("a t keyboard is online");
break;
case ITEM_OFFLINE:
XLine(FALSE);
Say("a t keyboard is offline");
break;
case ITEM_SYSTEMTEST:
if(SysTest_Item.Flags & CHECKED)
{
if(SysTestWindow==NULL)
{
SysTestWindow=Open("CON:20/10/600/150/ATKeyboard - System Test",MODE_NEWFILE);
if(SysTestWindow==NULL)
{
ClearMenuStrip(WindowPtr);
Inaktiv(&SysTest_Item);
SetMenuStrip(WindowPtr,&Menu1);
}
else
{ Say("opening test window"); }
ActivateWindow(WindowPtr);
}
}
else
{
if(SysTestWindow) Close(SysTestWindow);
Say("removing test window");
SysTestWindow=NULL;
}
break;
}
break;
case MENU_BEFEHLE:
if(Online==TRUE)
{
switch(ItemNum)
{
case ITEM_ANWENDUNGEN:
switch(SubItemNum)
{
case SUBITEM_PROGRAMMLISTE:
Say("open task list");
Tastenkombination(&PL);
break;
case SUBITEM_NEXT:
Say("run next program");
Tastenkombination(&NE);
break;
case SUBITEM_LAST:
Say("run previous program");
Tastenkombination(&LA);
break;
case SUBITEM_END:
Say("quit");
Tastenkombination(&EN);
break;
case SUBITEM_TEXTLADEN:
Say("load text");
Tastenkombination(&TxLad);
break;
case SUBITEM_TEXTSICHERN:
Say("save text");
Tastenkombination(&TxSi);
break;
case SUBITEM_LAYOUT:
Say("layout check");
Tastenkombination(&Lay);
break;
case SUBITEM_DRUCKEN:
Say("print");
Tastenkombination(&Drck);
break;
}
break;
case ITEM_DRUCK:
Say("hardcopy");
Tastenkombination(&Druck);
break;
case ITEM_BREAK:
Say("break");
Tastenkombination(&Break);
break;
case ITEM_US_EIN:
Say("turning on u s mode");
Tastenkombination(&USEin);
break;
case ITEM_US_AUS:
Say("turning off u s mode");
Tastenkombination(&USAus);
break;
case ITEM_MENGENKLAMMER_AUF:
Tastenkombination(&MKAuf);
break;
case ITEM_MENGENKLAMMER_ZU:
Tastenkombination(&MKZu);
break;
case ITEM_INDEXKLAMMER_AUF:
Tastenkombination(&IKAuf);
break;
case ITEM_INDEXKLAMMER_ZU:
Tastenkombination(&IKZu);
break;
case ITEM_APOSTROPH:
Tastenkombination(&Apo);
break;
case ITEM_UHRZEIT:
Say("inserting time");
UhrzeitEinsetzen();
break;
case ITEM_DATUM:
Say("inserting date");
DatumEinsetzen();
break;
case ITEM_RESET:
Say("warmstart");
Tastenkombination(&Reset);
break;
case ITEM_SETUP:
Say("a t setup");
Tastenkombination(&Setup);
break;
case ITEM_KALTSTART:
Say("coldstart");
ResetPC();
break;
}
}
break;
case MENU_SCHONER:
switch(ItemNum)
{
case ITEM_SCHONER_EIN:
if(Schoner==FALSE)
{
Schoner=TRUE;
KontrolliereSchoner();
}
break;
case ITEM_SCHONER_AUS:
if(Schoner==TRUE);
{
Schoner=FALSE;
KontrolliereSchoner();
}
break;
case ITEM_GRAFIK:
EinstellungenAendern();
break;
case ITEM_GRAFIKWECHSEL:
switch(SubItemNum)
{
case SUBITEM_GESCHWINDIGKEIT:
Einstellungen.GrafikGeschwindigkeit=Abfrage("Zeit pro Grafik in Sekunden:",
Einstellungen.GrafikGeschwindigkeit,
2,600,2);
break;
case SUBITEM_TASKPRIORITAET:
Einstellungen.SchonerPrioritaet=Abfrage("Priorität des Schonergrafik-Tasks:",
Einstellungen.SchonerPrioritaet,
-128,127,1);
break;
}
break;
case ITEM_FARBROLLEN:
switch(SubItemNum)
{
case SUBITEM_GESCHWINDIGKEIT:
Einstellungen.FarbrollGeschwindigkeit=Abfrage("Farbroll-Geschwindigkeit in 0.02s:",
Einstellungen.FarbrollGeschwindigkeit,
1,120,1);
break;
case SUBITEM_TASKPRIORITAET:
Einstellungen.FarbrollPrioritaet=Abfrage("Priorität des Farbroll-Tasks:",
Einstellungen.FarbrollPrioritaet,
-128,127,1);
break;
}
break;
case ITEM_PAL:
EinstellungenAendern();
break;
}
break;
case MENU_LPT1:
switch(ItemNum)
{
case ITEM_KONTROLLFENSTER:
if(Kontrollfenster_Item.Flags & CHECKED)
{
Einstellungen.Kontrollfenster=YES;
}
else
{
Einstellungen.Kontrollfenster=NO;
}
break;
case ITEM_DRUCKERRESET:
Druckerreset();
break;
case ITEM_DRUCKERCACHE:
switch(SubItemNum)
{
case SUBITEM_GROESSE:
Einstellungen.Puffergroesse=Abfrage("Größe des Druckerpuffers in Bytes:",
Einstellungen.Puffergroesse,
500,999999,2500);
break;
case SUBITEM_ZEIT:
Einstellungen.Leerungszeit=Abfrage("Leerungsabstand des Caches in 0.02s:",
Einstellungen.Leerungszeit,
3,2500,5);
break;
case SUBITEM_LED:
EinstellungenAendern();
break;
}
break;
case ITEM_DRUCKZIEL:
ClearMenuStrip(WindowPtr);
switch(SubItemNum)
{
case SUBITEM_PARALLEL:
Inaktiv(&ZuDatei_Item);
Inaktiv(&PrtPort_Item);
Aktiv(&ParPort_Item);
Say("the l p t 1 emulation will transfer the data to the parallel port after the next l p t 1 reset");
Einstellungen.Umlenkung=0;
break;
case SUBITEM_PRINTER:
Inaktiv(&ZuDatei_Item);
Inaktiv(&ParPort_Item);
Aktiv(&PrtPort_Item);
Say("the l p t 1 emulation will transfer the data to the printer driver chosen by preferences after the next l p t 1 reset");
Einstellungen.Umlenkung=1;
break;
case SUBITEM_DATEI:
Inaktiv(&ParPort_Item);
Inaktiv(&PrtPort_Item);
Aktiv(&ZuDatei_Item);
Say("the l p t 1 emulation will transfer the data to a file after the next l p t 1 reset");
Einstellungen.Umlenkung=2;
break;
case SUBITEM_DATEINAME:
Say("editing the l p t 1 output file's name");
if(FileRequester!=NULL)
{
name=FileReq("LPT1-Ausgabedatei","~(#?.info)");
}
else
{
name=StringAbfrage(FALSE,"Name der LPT1-Ausgabedatei:","");
}
strcpy(&Einstellungen.LPT1Name,name);
break;
}
SetMenuStrip(WindowPtr,&Menu1);
break;
}
break;
case MENU_ATPREFS:
ATPrefs(ItemNum,SubItemNum);
break;
case MENU_HIFI:
HiFi(ItemNum,SubItemNum);
break;
case MENU_HILFE:
Hilfe(ItemNum);
break;
break;
}
break;
case CLOSEWINDOW:
if(ARexxLock==0) CloseAll(); else DisplayBeep(NULL);
break;
}
IMessage=GetMsg(WindowPtr->UserPort);
} while(IMessage!=NULL);
}
}
if(Signale & ServiceSignalMask)
{
KopiereZeit();
TimeService=MakeBytePtr(TimeService);
JanusLock(&TimeService->ServiceDataLock);
TimeReq=MakeWordPtr(TimeReq);
TimeReq->Year=PublicTime->Year;
TimeReq=MakeBytePtr(TimeReq);
TimeReq->Month=PublicTime->Month;
TimeReq->Day=PublicTime->Day;
TimeReq->Seconds=PublicTime->Seconds;
TimeReq->Minutes=PublicTime->Minutes;
TimeReq->Hour=PublicTime->Hours;
sprintf(&TimeReq->String,"%s %s %02ld %02ld:%02ld:%02ld %ld%c%c%c",
TSRWochentage[PublicTime->DayNum],
TSRMonate[PublicTime->Month],
PublicTime->Day,
PublicTime->Hours,
PublicTime->Minutes,
PublicTime->Seconds,
PublicTime->Year,
13,10,36);
TimeReq=MakeWordPtr(TimeReq);
TimeReq->Err=0;
TimeReq=MakeBytePtr(TimeReq);
JanusUnlock(&TimeService->ServiceDataLock);
CallService(TimeService);
}
if(Signale & ARexxSignalMask)
{
RexxMsg=GetMsg(ARexxPort);
if(RexxMsg!=NULL)
{
if(ARexxIO_Item.Flags & CHECKED) bool=FALSE; else bool=TRUE;
HandleRexxMsg(RexxMsg,bool);
}
}
if(Signale & TimerTaskSignalMask)
{
if(Uhr==TRUE)
{
KopiereZeit();
SetAPen(RastPortPtr,1);
sprintf(Buffer,"%ld:%02ld:%02ld ",PublicTime->Hours,
PublicTime->Minutes,
PublicTime->Seconds);
WriteText(RastPortPtr,28,30,Buffer);
sprintf(Buffer,"%s, der %ld. %s %ld",Wochentage[PublicTime->DayNum],
PublicTime->Day,
Monate[PublicTime->Month],
PublicTime->Year);
WriteText(RastPortPtr,125,30,Buffer);
}
if(HiFiTime>0)
{
HiFiTime--;
if(HiFiTime==0)
{
HiFi(7466,0);
HiFiTime=-1;
}
}
if(RegWindow!=NULL)
{
if(RegTime>0)
{
RegTime--;
if(RegTime==0)
{
DeleteStdWindow(RegWindow);
RegWindow=NULL;
}
}
if(RegTime<0)
{
RegTime--;
if((RegTime % 4)==0) WindowToFront(RegWindow);
}
}
}
if(app!=NULL)
{
if(Signale & AppSignalMask)
{
AppMessage=GetMsg(app->Port);
if(AppMessage!=NULL)
{
ReplyMsg(AppMessage);
WindowToFront(WindowPtr);
ActivateWindow(WindowPtr);
XLine(TRUE);
}
}
}
}
}
/* *********************************************************************
****************** Unterprogramme ***********************************
********************************************************************* */
/* Abfrage-Routine */
LONG Abfrage(text,aktuell,min,max,pm)
UBYTE *text;
LONG aktuell,min,max,pm;
{
REGISTER BOOL ende=TRUE;
UBYTE B1[9];
REGISTER LONG i;
REGISTER UBYTE *Titel,*buffer;
ULONG Class;
UWORD id;
register struct Gadget *gad;
register struct Window *AbfrageWindow;
register struct RastPort *AbfrageRastPort;
register struct IntuiMessage *IMessage;
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,TitelText,TitelText);
if(Schoner==TRUE) WBenchToFront();
sprintf(&B1,"%ld",aktuell);
AbfrageWindow=CreateStdWindow("ATKeyboard - Einstellungen",75,75,450,38+BorderHeight(),
CLOSEWINDOW|GADGETUP,WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|ACTIVATE|GIMMEZEROZERO);
if(AbfrageWindow!=NULL)
{
/* ----- Gadgets und Text zeichnen --------------------- */
AbfrageRastPort=AbfrageWindow->RPort;
SetFont(AbfrageRastPort,OpalFont);
SelectStdFPen(AbfrageRastPort);
WriteText(AbfrageRastPort,10,13,text);
CreateBoolGadget(AbfrageWindow,15,20,100,12,"Okay",2);
CreateBoolGadget(AbfrageWindow,335,20,100,12,"Abbruch",3);
buffer=CreateIntegerGadget(AbfrageWindow,338,5,72,12,&B1,8,1);
CreateMinGadget(AbfrageWindow,313,5,20,12,10);
CreateMinGadget(AbfrageWindow,415,5,20,12,20);
DrawPTextBorder(AbfrageWindow,313,5,20,12,"«");
DrawPTextBorder(AbfrageWindow,415,5,20,12,"»");
/* ----- Abfrage --------------------------------------- */
ende=FALSE;
while(ende==FALSE)
{
WaitPort(AbfrageWindow->UserPort);
IMessage=GetMsg(AbfrageWindow->UserPort);
Class=IMessage->Class;
gad=IMessage->IAddress;
ReplyMsg(IMessage);
switch(Class)
{
case CLOSEWINDOW:
i=aktuell;
ende=TRUE;
break;
case GADGETUP:
id=gad->GadgetID;
i=atol(buffer);
switch(id)
{
case 1:
case 2:
if(i>max) i=max;
if(i<min) i=min;
ende=TRUE;
break;
case 10:
i=i-pm;
if(i>max) i=max;
if(i<min) i=min;
sprintf(buffer,"%ld",i);
RefreshGadgets(AbfrageWindow->FirstGadget,AbfrageWindow,NULL);
break;
case 20:
i=i+pm;
if(i>max) i=max;
if(i<min) i=min;
sprintf(buffer,"%ld",i);
RefreshGadgets(AbfrageWindow->FirstGadget,AbfrageWindow,NULL);
break;
case 3:
i=aktuell;
ende=TRUE;
break;
}
break;
}
}
}
else
{
i=aktuell;
}
if(Schoner==TRUE) ScreenToFront(SchonerScreen);
CloseWindow(AbfrageWindow);
ActivateWindow(WindowPtr);
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
return(i);
}
/* Abfrage-Routine für Strings */
UBYTE *StringAbfrage(bool,text,aktuell)
BOOL bool;
UBYTE *text;
UBYTE *aktuell;
{
REGISTER UBYTE *Titel;
REGISTER UBYTE *r,*buffer;
ULONG Class;
UWORD id;
register struct Gadget *gad;
register struct Window *AbfrageWindow;
register struct RastPort *AbfrageRastPort;
register struct IntuiMessage *IMessage;
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,TitelText,TitelText);
if(Schoner==TRUE) WBenchToFront();
r=aktuell;
AbfrageWindow=CreateStdWindow("ATKeyboard - Einstellungen",75,75,450,52+BorderHeight(),
CLOSEWINDOW|GADGETUP,WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE|GIMMEZEROZERO);
if(AbfrageWindow!=NULL)
{
/* ----- Gadgets und Text zeichnen --------------------- */
AbfrageRastPort=AbfrageWindow->RPort;
SetFont(AbfrageRastPort,OpalFont);
SelectStdFPen(AbfrageRastPort);
buffer=CreateStringGadget(AbfrageWindow,15,18,420,12,r,128,1);
CreateBoolGadget(AbfrageWindow,15,34,100,12,"Okay",2);
CreateBoolGadget(AbfrageWindow,335,34,100,12,"Abbruch",3);
WriteText(AbfrageRastPort,20,12,text);
/* ----- Abfrage --------------------------------------- */
WaitPort(AbfrageWindow->UserPort);
IMessage=GetMsg(AbfrageWindow->UserPort);
Class=IMessage->Class;
gad=IMessage->IAddress;
ReplyMsg(IMessage);
id=3;
if(Class==GADGETUP) id=gad->GadgetID;
if(Schoner==TRUE) ScreenToFront(SchonerScreen);
DeleteStdWindow(AbfrageWindow);
ActivateWindow(WindowPtr);
switch(id)
{
case 1:
case 2:
r=buffer;
break;
default:
if(bool==FALSE) r=aktuell; else r=NULL;
break;
}
}
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
return(r);
}
/* Tastendruck an PC senden */
VOID Taste(AmigaCode,Qualifier)
UBYTE AmigaCode;
UWORD Qualifier;
{
REGISTER UBYTE PCCode,s;
if(SysTestWindow)
{
sprintf(Buffer,"Amiga-Taste <$%02lx> gedrückt.\n",AmigaCode);
Write(SysTestWindow,Buffer,strlen(Buffer));
}
PCCode=TastenTabelle[AmigaCode];
if((Qualifier & IEQUALIFIER_LCOMMAND)
|| (Qualifier & IEQUALIFIER_RCOMMAND)
|| (PCCode==0xFF))
{
if(Einstellungen.Tastenfilter) return;
}
if((PCCode & BIT7) && (!(Einstellungen.Tastenruecknahme))) return;
if((Qualifier & IEQUALIFIER_REPEAT) && (!(Einstellungen.Tastenwiederholung))) return;
switch(AmigaCode)
{
case 0xe0:
kstatus.LShift=0;
break;
case 0x60:
kstatus.LShift=1;
break;
case 0xe1:
kstatus.RShift=0;
break;
case 0x61:
kstatus.RShift=1;
break;
case 0xe4:
case 0xe5:
kstatus.Alt=0;
break;
case 0x64:
case 0x65:
kstatus.Alt=1;
break;
case 0xe3:
kstatus.Ctrl=0;
break;
case 0x63:
kstatus.Ctrl=1;
break;
}
if(Einstellungen.ATStatus)
{
Disable();
atstatus->Valid=0;
s=0;
if(Qualifier & IEQUALIFIER_CAPSLOCK) s+=STATUS_CAPS;
if(kstatus.LShift) s+=STATUS_LSHIFT;
if(kstatus.RShift) s+=STATUS_RSHIFT;
if(kstatus.Alt) s+=STATUS_ALT;
if(kstatus.Ctrl) s+=STATUS_CTRL;
atstatus->Status=s;
s=0;
if(kstatus.Alt) s+=EXTSTATUS_ALT_DOWN;
if(kstatus.Ctrl) s+=EXTSTATUS_CONTROL_DOWN;
atstatus->ExtStatus=s;
atstatus->Valid=0xFF;
Enable();
}
else
atstatus->Valid=0;
switch(AmigaCode)
{
case 0x62:
case 0x62|BIT7:
Sendung(0xba);
Delay(Einstellungen.Uebertragungsrate);
if(Einstellungen.WarteAufInt) Wait(KeyboardSignalMask);
Sendung(0x3a);
break;
default:
if(SysTestWindow)
{
sprintf(Buffer," Übertragung als PC-Taste <$%02lx>.\n",PCCode);
Write(SysTestWindow,Buffer,strlen(Buffer));
}
Sendung(PCCode);
if(Einstellungen.WarteAufInt) Wait(KeyboardSignalMask);
break;
}
Delay(Einstellungen.Uebertragungsrate);
}
/* Tastenkombination an PC senden */
VOID Tastenkombination(array)
UBYTE *array;
{
REGISTER WORD i;
REGISTER UBYTE PCCode;
if(SysTestWindow)
{
strcpy(Buffer,"Tastenkombination im Menü gewählt\n");
Write(SysTestWindow,Buffer,strlen(Buffer));
}
for(i=0;i<array[0];i++)
{
PCCode=TastenTabelle[array[i+1]];
if(SysTestWindow)
{
sprintf(Buffer," Übertragung Amiga-Taste <$%02lx> zu PC-Taste <$%02lx>.\n",array[i+1],PCCode);
Write(SysTestWindow,Buffer,strlen(Buffer));
}
Sendung(PCCode);
Delay(Einstellungen.Uebertragungsrate);
if(Einstellungen.WarteAufInt) Wait(KeyboardSignalMask);
}
}
/* Uhrzeit in Textform an PC senden */
UBYTE AsciiTab[]={'0','1','2','3','4','5','6','7','8','9',' ','.'};
UBYTE RawTab[]={0xA,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x40,0x39};
VOID UhrzeitEinsetzen()
{
REGISTER WORD i,j,k,l;
UBYTE TextBuffer[35];
KopiereZeit();
sprintf(Buffer,"%ld:%02ld:%02ld",PublicTime->Hours,
PublicTime->Minutes,
PublicTime->Seconds);
j=strlen(Buffer);
k=2;
TextBuffer[1]=0x60|BIT7;
for(i=0;i<j;i++)
{
switch(Buffer[i])
{
case ':':
TextBuffer[k]=0x60; k++;
TextBuffer[k]=0x39; k++;
TextBuffer[k]=0x39|BIT7; k++;
TextBuffer[k]=0x60|BIT7; k++;
break;
default:
for(l=0;l<=11;l++)
{
if(AsciiTab[l]==Buffer[i])
{
TextBuffer[k]=RawTab[l]; k++;
TextBuffer[k]=RawTab[l]|BIT7; k++;
}
}
break;
}
}
TextBuffer[0]=k-1;
Tastenkombination(&TextBuffer);
}
/* Datum in Textform an PC senden */
VOID DatumEinsetzen()
{
REGISTER WORD i,j,k,l;
UBYTE TextBuffer[35];
KopiereZeit();
sprintf(Buffer,"%ld. %ld. %ld",PublicTime->Day,
PublicTime->Month,
PublicTime->Year);
j=strlen(Buffer);
k=2;
TextBuffer[1]=0x60|BIT7;
for(i=0;i<j;i++)
{
for(l=0;l<=11;l++)
{
if(AsciiTab[l]==Buffer[i])
{
TextBuffer[k]=RawTab[l]; k++;
TextBuffer[k]=RawTab[l]|BIT7; k++;
}
}
}
TextBuffer[0]=k-1;
Tastenkombination(&TextBuffer);
}
/* PC-Code senden */
#asm
public _Sendung
_Sendung:
movem.l a1-a2/d7,-(sp)
move.l 16(sp),d7
move.l _JanusStart,a1
move.l a1,a2
adda.l #516096,a1
moveq.l #0,d0
move.l _JanusBase,a6
move.w 114(a6),d0
add.l d0,a1
adda.l #524283,a2
move.b d7,(a1)
move.b #-1,(a2)
movem.l (sp)+,a1-a2/d7
rts
; Implementation von CacheControl
; (ab Kickstart 2.0)
public _CacheControl
_CacheControl:
move.l 4(sp),d0
move.l 8(sp),d1
move.l a6,-(sp)
move.l $4,a6
jsr -648(a6)
move.l (sp)+,a6
rts
#endasm
/* Online/Offline wählen */
VOID XLine(xline)
BOOL xline;
{
REGISTER BOOL bool;
if(xline==TRUE)
{
if(Online==FALSE)
{
ClearMenuStrip(WindowPtr);
Inaktiv(&Offline_Item);
Aktiv(&Online_Item);
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,OnlineText,TitelText);
if(KeyboardInt==NULL)
{
KeyboardInt=SetupJanusSig(JSERV_ENBKB,KeyboardSignal,16,MEMF_PARAMETER|MEM_BYTEACCESS);
if(KeyboardInt==NULL)
{
do
{
bool=Requester("Der Tastatur-Interrupt ist durch",
"ein anderes Programm belegt.","Weiter","Abbruch");
if(bool==TRUE)
{
KeyboardInt=SetupJanusSig(JSERV_ENBKB,KeyboardSignal,16,MEMF_PARAMETER|MEM_BYTEACCESS);
}
else
{
CloseAll();
}
} while(KeyboardInt==NULL);
}
atstatus=KeyboardInt->ss_ParamPtr;
}
Online=TRUE;
}
}
else
{
if(Online==TRUE)
{
ClearMenuStrip(WindowPtr);
Inaktiv(&Online_Item);
Aktiv(&Offline_Item);
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,OfflineText,TitelText);
if(Einstellungen.IntFreigabe)
{
CleanupJanusSig(KeyboardInt);
KeyboardInt=NULL;
}
Online=FALSE;
}
}
}
/* Tastaturmodus ändern */
VOID NeuerModus(num,menue)
WORD num;
BOOL menue;
{
REGISTER WORD i;
if((num>=0)&&(num<=7))
{
if(menue==TRUE) ClearMenuStrip(WindowPtr);
for(i=0;i<=7;i++)
{
Inaktiv(&TM_Item[i]);
}
Aktiv(&TM_Item[num]);
SetzeTM(num);
if(menue==TRUE) SetMenuStrip(WindowPtr,&Menu1);
}
}
/* Alte Messages entfernen */
VOID LeerePort(p)
struct MsgPort *p;
{
NewList(&p->mp_MsgList);
}
/* Alte IDCMP-Messages entfernen */
VOID LeereIDCMP(win)
struct Window *win;
{
register struct IntuiMessage *IMessage;
IMessage=GetMsg(win->UserPort);
if(IMessage!=NULL)
{
do
{
ReplyMsg(IMessage);
IMessage=GetMsg(win->UserPort);
} while(IMessage!=NULL);
}
}
/* Prüfen, ob TimeService ein- oder ausgeschaltet werden muß */
VOID KontrolliereService()
{
REGISTER UBYTE *Titel;
REGISTER LONG i;
if((Service==TRUE)&&(TimeService==NULL))
{
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,"Installiere TimeService... Bitte warten. ",TitelText);
Say("starting the time service");
SHelp->A=NULL;
i=AddService(SHelp,TIMESERV_APPID,TIMESERV_LOCID,
sizeof(struct TimeServReq),MEMF_BUFFER,ServiceSignal,
ADDS_TOPC_ONLY);
if(i!=JSERV_OK)
{
Service=FALSE;
TimeService=NULL;
ClearMenuStrip(WindowPtr);
Inaktiv(&TimeService_Item);
SetMenuStrip(WindowPtr,&Menu1);
Requester("Der TimeService konnte nicht","installiert werden.","Okay",NULL);
}
else
{
TimeService=SHelp->A;
TimeService=MakeWordPtr(TimeService);
TimeReq=JanusOffsetToMem(TimeService->MemOffset,MEMF_BUFFER);
}
LeereIDCMP(WindowPtr);
SetWindowTitles(WindowPtr,Titel,TitelText);
}
if((Service==FALSE)&&(TimeService!=NULL))
{
Say("removing the time service");
DeleteService(TimeService);
TimeService=NULL;
}
}
/* Prüfen, ob Uhr ein- oder ausgeschaltet werden muß */
VOID KontrolliereUhr()
{
if(Clock==TRUE)
{
if(Uhr==FALSE)
{
if(WindowPtr->Height==WindowDef.Height)
{
if(WindowPtr->TopEdge>=(WindowPtr->WScreen->Height-25))
{
MoveWindow(WindowPtr,0,-25);
}
SizeWindow(WindowPtr,0,20);
}
Uhr=TRUE;
Say("clock turned on");
if(!(WindowPtr->Flags & ZOOMED)) WindowPtr->Flags += ZOOMED;
}
}
else
{
if(Uhr==TRUE)
{
if(WindowPtr->Height==ZoomArray[3]) SizeWindow(WindowPtr,0,-20);
Uhr=FALSE;
Say("clock turned off");
if(WindowPtr->Flags & ZOOMED) WindowPtr->Flags -= ZOOMED;
}
}
}
/* Teste, ob FPU ein- oder ausgeschaltet werden muß */
VOID KontrolliereFPU()
{
if(Schoner==FALSE)
{
if(M68881_Item.Flags & ITEMENABLED)
{
if(M68881_Item.Flags & CHECKED) FPU=1; else FPU=0;
}
else
{
FPU=0;
}
}
}
VOID KontrolliereCPU()
{
if(SysBase->AttnFlags & AFF_68030)
{
if(KickstartVersion>=36)
{
if(Einstellungen.DataCache)
{
CacheControl(CACRF_EnableD,CACRF_EnableD|CACRF_FreezeD);
}
else
{
CacheControl(CACRF_FreezeD,CACRF_EnableD|CACRF_FreezeD);
}
}
}
if(SysBase->AttnFlags & AFF_68030)
{
if(Einstellungen.DataCache) CPU=1; else CPU=0;
}
}
/* Zeit in öffentlichen Bereich kopieren */
VOID KopiereZeit()
{
Forbid();
CopyMem(SystemTime,PublicTime,sizeof(struct SystemTime));
Permit();
}
/* Timer-Task erstellen */
UBYTE *TimerTaskName="ATKeyboard Timer Task by Thomas Dreibholz";
BOOL ErstelleTimerTask()
{
SubTask=CreateProcess(TimerTask,1500,TimerTaskName,0);
if(SubTask!=NULL) return(TRUE); else return(FALSE);
}
/* Task zur Steuerung der Uhr */
ULONG TageProMonat[]={00,31,28,31,
30,31,30,31,
31,30,31,30,
31};
VOID TimerTask()
{
REGISTER ULONG Tage,Jahr,Monat;
register struct Message *msg;
geta4();
SystemTime->OldDays=0x0FFFFFFF;
msg=NULL;
do
{
DateStamp(SystemTime);
Forbid();
Tage=SystemTime->DateStamp.ds_Days;
SystemTime->Hours=DivU32(SystemTime->DateStamp.ds_Minute,60);
SystemTime->Minutes=SystemTime->DateStamp.ds_Minute%60;
SystemTime->Seconds=DivU32(SystemTime->DateStamp.ds_Tick,TICKS_PER_SECOND);
SystemTime->DayNum=Tage%7;
if(Tage!=SystemTime->OldDays)
{
SystemTime->OldDays=Tage;
Jahr=1978;
while(Tage>365)
{
if((Jahr%4)==0) Tage-=366; else Tage-=365;
Jahr++;
}
if((Tage==365) && !((Jahr%4)==0)) Tage-=365;
if((Jahr%4)==0) TageProMonat[2]=29; else TageProMonat[2]=28;
Monat=1;
while(Tage>=TageProMonat[Monat])
{
Tage-=TageProMonat[Monat];
Monat++;
}
Tage++;
SystemTime->Year=Jahr;
SystemTime->Month=Monat;
SystemTime->Day=Tage;
}
Permit();
Signal(MainTask,TimerTaskSignalMask);
Delay(40);
msg=GetMsg(Port4);
} while(msg==NULL);
ReplyMsg(msg);
Exit(0);
}
/* Menüpunkt abhaken */
VOID Aktiv(item)
struct MenuItem *item;
{
item->Flags |= CHECKED;
}
/* Menühaken entfernen */
VOID Inaktiv(item)
struct MenuItem *item;
{
item->Flags &= xCHECKED;
}
/* Informationen zum Programm */
VOID ShowInformation(aktiv)
BOOL aktiv;
{
REGISTER UBYTE *Titel;
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,TitelText,TitelText);
ExtInformationBox(NULL,"ATKeyboard - Information",
Copyright[0],Copyright[1],
Copyright[2],Copyright[3],
ATName,&idata);
if(aktiv==TRUE) ActivateWindow(WindowPtr);
SetWindowTitles(WindowPtr,Titel,TitelText);
}
/* Tastaturtabelle laden */
VOID LadeTabelle(num)
UWORD num;
{
register struct FileHandle *fh;
REGISTER UWORD i;
fh=Open(TabellenDatei,MODE_OLDFILE);
if(fh!=NULL)
{
i=Read(fh,KeyCodes,sizeof(struct KeyCodes));
if(i==sizeof(struct KeyCodes))
{
KeyCodes->KeyTab[0].Valid=1;
if(KeyCodes->KeyTab[num].Valid==0) num=0;
for(i=0;i<256;i++)
{
TastenTabelle[i]=KeyCodes->KeyTab[num].Keys[i];
}
for(i=0;i<=7;i++)
{
TM_Text[i].IText=&KeyCodes->KeyTab[i].Name;
if(!(KeyCodes->KeyTab[i].Valid)) TM_Item[i].Flags &= xITEMENABLED;
}
Aktiv(&TM_Item[num]);
Einstellungen.Tastaturmodus=num;
}
else
{
Fehlerbehandlung(TRUE,"ATKeyboard - Inkompatible T-Datei");
}
Close(fh);
}
else
{
Fehlerbehandlung(TRUE,"ATKeyboard - Keine Tabellendatei");
}
}
/* Einstellungen laden */
VOID LadeEinstellungen(tab)
BOOL tab;
{
struct FileHandle *fh;
fh=Open(EinstellungsDatei,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&Einstellungen,sizeof(struct Einstellungen));
Close(fh);
}
if(tab==TRUE)
{
fh=Open(TabellenDatei,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,KeyCodes,sizeof(struct KeyCodes));
Close(fh);
}
}
ARexxName=&Einstellungen.ARexxName;
}
/* Einstellungen sichern */
VOID SichereEinstellungen()
{
struct FileHandle *fh;
strcpy(&Einstellungen.ARexxName,ARexxName);
fh=Open(EinstellungsDatei,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,&Einstellungen,sizeof(struct Einstellungen));
Close(fh);
}
fh=Open(TabellenDatei,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,KeyCodes,sizeof(struct KeyCodes));
Close(fh);
}
}
/* Einstellungen sicherbar machen */
VOID ZeigeEinstellungen(menue)
BOOL menue;
{
REGISTER WORD i;
if(menue==TRUE) ClearMenuStrip(WindowPtr);
NeuerModus(Einstellungen.Tastaturmodus,FALSE);
if(Einstellungen.Kontrollfenster)
Aktiv(&Kontrollfenster_Item); else Inaktiv(&Kontrollfenster_Item);
if(Einstellungen.Tastenfilter)
Aktiv(&Tastenfilter_Item); else Inaktiv(&Tastenfilter_Item);
if(Einstellungen.ATStatus)
Aktiv(&Status_Item); else Inaktiv(&Status_Item);
if(Einstellungen.Tastenruecknahme)
Aktiv(&Tastenruecknahme_Item); else Inaktiv(&Tastenruecknahme_Item);
if(Einstellungen.Tastenwiederholung)
Aktiv(&Tastenwiederholung_Item); else Inaktiv(&Tastenwiederholung_Item);
if(Einstellungen.WarteAufInt)
Aktiv(&WarteAufInt_Item); else Inaktiv(&WarteAufInt_Item);
if(Einstellungen.Bildschirmschoner)
Aktiv(&Bildschirmschoner_Item); else Inaktiv(&Bildschirmschoner_Item);
if(Einstellungen.AutoStart)
Aktiv(&AutoStart_Item); else Inaktiv(&AutoStart_Item);
if(Einstellungen.LPT1Verwaltung)
Aktiv(&LPT1_Item); else Inaktiv(&LPT1_Item);
if(Einstellungen.TimeService)
Aktiv(&TimeService_Item); else Inaktiv(&TimeService_Item);
if(Einstellungen.Speak)
Aktiv(&Speak_Item); else Inaktiv(&Speak_Item);
if(Einstellungen.Uhr)
Aktiv(&Uhr_Item); else Inaktiv(&Uhr_Item);
if(Einstellungen.IntFreigabe)
Aktiv(&IntFreigabe_Item); else Inaktiv(&IntFreigabe_Item);
for(i=0;i<=15;i++)
{
if(Einstellungen.Gfx[i]) Aktiv(&Gfx_Item[i]); else Inaktiv(&Gfx_Item[i]);
}
if(Einstellungen.SystemPAL)
Aktiv(&PAL_Item); else Inaktiv(&PAL_Item);
if(Einstellungen.Maus)
Aktiv(&Maus_Item); else Inaktiv(&Maus_Item);
if(Einstellungen.A2286)
{
Setup_Item.Flags |= ITEMENABLED;
Aktiv(&A2286_Item);
}
else
{
Setup_Item.Flags &= xITEMENABLED;
Inaktiv(&A2286_Item);
}
if(Einstellungen.M68881)
Aktiv(&M68881_Item); else Inaktiv(&M68881_Item);
if(Einstellungen.M68020)
Aktiv(&M68020_Item); else Inaktiv(&M68020_Item);
if(Einstellungen.DataCache)
Aktiv(&DataCache_Item); else Inaktiv(&DataCache_Item);
if(Einstellungen.SichernBeiEnde)
Aktiv(&SichernBeiEnde_Item); else Inaktiv(&SichernBeiEnde_Item);
if(Einstellungen.ARexxIO)
Aktiv(&ARexxIO_Item); else Inaktiv(&ARexxIO_Item);
if(Einstellungen.LED)
Aktiv(&DSWarnung_Item); else Inaktiv(&DSWarnung_Item);
switch(Einstellungen.Umlenkung)
{
case 0:
Inaktiv(&ZuDatei_Item); Aktiv(&ParPort_Item); Inaktiv(&PrtPort_Item);
break;
case 1:
Inaktiv(&ZuDatei_Item); Inaktiv(&ParPort_Item); Aktiv(&PrtPort_Item);
break;
case 2:
Aktiv(&ZuDatei_Item); Inaktiv(&ParPort_Item); Inaktiv(&PrtPort_Item);
break;
}
Aktiv(&TM_Item[0]);
for(i=0;i<=7;i++) Inaktiv(&TM_Item[i]);
if(Einstellungen.TastaturmodusSichern)
{
Aktiv(&TModusSichern_Item);
if((Einstellungen.Tastaturmodus>=0)&&(Einstellungen.Tastaturmodus<=7))
{
Inaktiv(&TM_Item[0]);
Aktiv(&TM_Item[Einstellungen.Tastaturmodus]);
SetzeTM(Einstellungen.Tastaturmodus);
}
else
{
Einstellungen.Tastaturmodus=0;
}
}
else Inaktiv(&TModusSichern_Item);
if(menue==TRUE) SetMenuStrip(WindowPtr,&Menu1);
if(Einstellungen.Uhr) Clock=TRUE; else Clock=FALSE;
if(Einstellungen.TimeService) Service=TRUE; else Service=FALSE;
if(Einstellungen.LPT1Verwaltung) LPT1=TRUE; else LPT1=FALSE;
if(Einstellungen.Speak) Speak=TRUE; else Speak=FALSE;
KontrolliereUhr();
if(menue==TRUE)
{
KontrolliereService();
KontrolliereLPT1();
KontrolliereFPU();
KontrolliereCPU();
}
}
/* Einstellungen ändern */
VOID EinstellungenAendern()
{
REGISTER WORD i;
if(Tastenfilter_Item.Flags & CHECKED)
Einstellungen.Tastenfilter=YES; else Einstellungen.Tastenfilter=NO;
if(Status_Item.Flags & CHECKED)
Einstellungen.ATStatus=YES; else Einstellungen.ATStatus=NO;
if(Tastenruecknahme_Item.Flags & CHECKED)
Einstellungen.Tastenruecknahme=YES; else Einstellungen.Tastenruecknahme=NO;
if(Tastenwiederholung_Item.Flags & CHECKED)
Einstellungen.Tastenwiederholung=YES; else Einstellungen.Tastenwiederholung=NO;
if(WarteAufInt_Item.Flags & CHECKED)
Einstellungen.WarteAufInt=YES; else Einstellungen.WarteAufInt=NO;
if(Bildschirmschoner_Item.Flags & CHECKED)
Einstellungen.Bildschirmschoner=YES; else Einstellungen.Bildschirmschoner=NO;
if(AutoStart_Item.Flags & CHECKED)
Einstellungen.AutoStart=YES; else Einstellungen.AutoStart=NO;
if(LPT1_Item.Flags & CHECKED)
Einstellungen.LPT1Verwaltung=YES; else Einstellungen.LPT1Verwaltung=NO;
if(TimeService_Item.Flags & CHECKED)
Einstellungen.TimeService=YES; else Einstellungen.TimeService=NO;
if(Uhr_Item.Flags & CHECKED)
Einstellungen.Uhr=YES; else Einstellungen.Uhr=NO;
if(IntFreigabe_Item.Flags & CHECKED)
Einstellungen.IntFreigabe=YES; else Einstellungen.IntFreigabe=NO;
if(A2286_Item.Flags & CHECKED)
Einstellungen.A2286=YES; else Einstellungen.A2286=NO;
if(M68881_Item.Flags & CHECKED)
Einstellungen.M68881=YES; else Einstellungen.M68881=NO;
if(M68020_Item.Flags & CHECKED)
Einstellungen.M68020=YES; else Einstellungen.M68020=NO;
if(DataCache_Item.Flags & CHECKED)
Einstellungen.DataCache=YES; else Einstellungen.DataCache=NO;
if(SichernBeiEnde_Item.Flags & CHECKED)
Einstellungen.SichernBeiEnde=YES; else Einstellungen.SichernBeiEnde=NO;
if(ARexxIO_Item.Flags & CHECKED)
Einstellungen.ARexxIO=YES; else Einstellungen.ARexxIO=NO;
if(TModusSichern_Item.Flags & CHECKED)
Einstellungen.TastaturmodusSichern=YES; else Einstellungen.TastaturmodusSichern=NO;
if(Speak_Item.Flags & CHECKED)
Einstellungen.Speak=YES; else Einstellungen.Speak=NO;
for(i=0;i<=15;i++)
{
if(Gfx_Item[i].Flags & CHECKED)
Einstellungen.Gfx[i]=YES; else Einstellungen.Gfx[i]=NO;
}
if(Maus_Item.Flags & CHECKED)
Einstellungen.Maus=YES; else Einstellungen.Maus=NO;
if(PAL_Item.Flags & CHECKED)
Einstellungen.SystemPAL=YES; else Einstellungen.SystemPAL=NO;
if(DSWarnung_Item.Flags & CHECKED)
Einstellungen.LED=YES; else Einstellungen.LED=NO;
}
/* System installieren */
VOID OpenAll()
{
register struct Screen *scr;
register struct ConfigDev *card;
register struct FileHandle *fh;
REGISTER BOOL bool;
REGISTER LONG num;
/* ----- Variablen installieren --------------------------------------- */
KickstartVersion=SysBase->lib_Node.lib_Version;
if(KickstartVersion<36) Menu7.Flags &= xMENUENABLED;
MainTask=FindTask(NULL);
Uhr=FALSE;
SystemOK=FALSE;
Schoner=FALSE;
Service=FALSE;
Clock=FALSE;
ARexx=FALSE;
LPT1=FALSE;
Speak=FALSE;
FPU=0;
CPU=0;
ARexxLock=0;
ARexxMenuLock=0;
/* ----- Libraries öffnen --------------------------------------------- */
IntuitionBase=OpenLibrary("intuition.library",0L);
GfxBase=OpenLibrary("graphics.library",0L);
if((IntuitionBase==NULL)||(GfxBase==NULL)) CloseAll();
/* ----- AutoStart ausführen ------------------------------------------ */
NIL=Open("NIL:",MODE_NEWFILE);
if(NIL==NULL)
{
printf("FEHLER: Kann NIL: nicht als Ausgabegerät öffnen!\n");
CloseAll();
}
LadeEinstellungen(FALSE);
if(Einstellungen.AutoStart)
{
KontrolliereCPU();
Execute(AutoStartCmd,NULL,NIL);
}
/* ----- Fenster öffnen ----------------------------------------------- */
scr=OpenWorkBench();
WindowDef.Height=scr->WBorTop+scr->Font->ta_YSize+1;
ZoomArray[3]=WindowDef.Height+20;
WindowPtr=OpenWindow(&WindowDef);
if(WindowPtr==NULL)
{
printf("FEHLER: Kann Fenster nicht öffnen!\n");
CloseAll();
}
RastPortPtr=WindowPtr->RPort;
/* ----- ATUtilities -------------------------------------------------- */
ATUtilitiesBase=OpenLibrary("at-utilities.library",0);
if(ATUtilitiesBase==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Keine ATUtilities-Library");
}
Erweiterungen_Item.SubItem=CreateUtilityList();
/* ----- Opal/9-Font und Times/24-Font laden -------------------------- */
DiskfontBase=OpenLibrary("diskfont.library",0L);
if(DiskfontBase==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Keine Diskfont-Library");
OpalFont=OpenDiskFont(&OpalFontDef);
if(OpalFont==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Kann Opal-Font nicht laden");
SchonerFont=OpenDiskFont(&TimesFontDef);
SetFont(RastPortPtr,OpalFont);
/* ----- Weitere Libraries öffnen und testen, ob PC-Karte vorhanden --- */
ExpansionBase=OpenLibrary("expansion.library",0L);
if(ExpansionBase!=NULL)
{
card=FindConfigDev(NULL,513,-1);
}
if(card==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Keine PC/AT-Karte gefunden");
IconBase=OpenLibrary("icon.library",0L);
if(IconBase==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Keine Icon-Library");
if(ATName==NULL)
{
ATName=WBenchMsg->sm_ArgList->wa_Name;
}
UtilityBase=OpenLibrary("utility.library",0L);
AslBase=OpenLibrary("asl.library",0L);
if((UtilityBase!=NULL)&&(AslBase!=NULL))
{
FRTags=AllocateTagItems(6L);
if(FRTags!=NULL)
{
FRTags[0].ti_Tag=ASL_Pattern;
FRTags[0].ti_Data=NULL;
FRTags[1].ti_Tag=ASL_FuncFlags;
FRTags[1].ti_Data=FILF_PATGAD;
FRTags[2].ti_Tag=ASL_Hail;
FRTags[2].ti_Data=NULL;
FRTags[3].ti_Tag=TAG_DONE;
FRTags[4].ti_Tag=TAG_DONE;
FRTags[5].ti_Tag=TAG_DONE;
FileRequester=AllocFileRequest();
}
}
/* ----- Mathematische Libraries öffnen ------------------------------- */
MathBase=OpenLibrary("mathffp.library",0L);
MathTransBase=OpenLibrary("mathtrans.library",0L);
if((MathBase==NULL)||(MathTransBase==NULL))
{
Fehlerbehandlung(TRUE,"ATKeyboard - Keine MathTrans-Library");
}
/* ----- Translator-Library öffnen ------------------------------------ */
TranslatorBase=OpenLibrary("translator.library",0L);
if(TranslatorBase==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Keine Translator-Library");
}
/* ----- Message-Ports erstellen -------------------------------------- */
Port1=CreatePort("ATKeyboard Schoner Task <Stop>",0L);
Port2=CreatePort("ATKeyboard Color Cycling Task <Stop>",0L);
Port3=CreatePort("ATKeyboard Stop Reply Port",0L);
Port4=CreatePort("ATKeyboard Timer Task <Stop>",0L);
Port5=CreatePort("ATKeyboard Printer Task <Stop>",0L);
ParallelPort=CreatePort("ATKeyboard Parallel Device Transfer Port",0L);
if( (Port1==NULL) || (Port2==NULL) ||
(Port3==NULL) || (Port4==NULL) ||
(Port5==NULL) || (ParallelPort==NULL) )
{
Fehlerbehandlung(TRUE,"ATKeyboard - Kann Ports nicht erstellen");
}
ParallelRequest=CreateExtIO(ParallelPort,sizeof(struct IOExtPar));
if(ParallelRequest==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Kann IOExtPar nicht erstellen");
}
/* ----- Janus-Library öffnen ----------------------------------------- */
JanusBase=OpenLibrary("janus.library",0L);
if(JanusBase==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Janus-Library nicht gefunden");
}
JanusStart=GetJanusStart();
/* ----- Signale belegen ---------------------------------------------- */
KeyboardSignal=AllocSignal(-1L);
ServiceSignal=AllocSignal(-1L);
TimerTaskSignal=AllocSignal(-1L);
if((KeyboardSignal==-1)||(ServiceSignal==-1)||(TimerTaskSignal==-1))
{
Fehlerbehandlung(TRUE,"ATKeyboard - Keine freien Task-Signale");
}
IntuitionSignal=WindowPtr->UserPort->mp_SigBit;
KeyboardSignalMask=(1L<<KeyboardSignal);
ServiceSignalMask=(1L<<ServiceSignal);
TimerTaskSignalMask=(1L<<TimerTaskSignal);
IntuitionSignalMask=(1L<<IntuitionSignal);
WaitSignalMask=KeyboardSignalMask+
ServiceSignalMask+
TimerTaskSignalMask+
IntuitionSignalMask;
/* ----- Einstellungen von Diskette laden ----------------------------- */
KeyCodes=AllocMem(sizeof(struct KeyCodes),MEMF_CLEAR|MEMF_PUBLIC);
if(KeyCodes==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Nicht genug Speicher");
if(Einstellungen.TastaturmodusSichern)
{
num=Einstellungen.Tastaturmodus;
if(!((num>=0)&&(num<=7))) num=0;
LadeTabelle(num);
}
else
{
LadeTabelle(0);
}
SetTaskPri(MainTask,Einstellungen.Prioritaet);
if(Einstellungen.Bildschirmschoner) Schoner=TRUE;
if(Einstellungen.TimeService) Service=TRUE;
if(Einstellungen.Uhr) Clock=TRUE;
if(Einstellungen.LPT1Verwaltung) LPT1=TRUE;
LiesATP();
/* ----- Prüfen, ob Coprozessor vorhanden ----------------------------- */
bool=FALSE;
if(SysBase->AttnFlags & AFF_68881) bool=TRUE;
if(SysBase->AttnFlags & AFF_68882) bool=TRUE;
if(bool) M68881_Item.Flags |= ITEMENABLED;
KontrolliereFPU();
/* ----- Prüfen, ob 68020/68030 vorhanden ----------------------------- */
if((SysBase->AttnFlags & AFF_68030)&&(KickstartVersion>=36))
{
DataCache_Item.Flags |= ITEMENABLED;
}
KontrolliereCPU();
if(SysBase->AttnFlags & AFF_68020)
{
M68020_Item.Flags |= ITEMENABLED;
}
/* ----- Einstellugen im Menü abhaken und Menü-Strip darstellen ------- */
ZeigeEinstellungen(FALSE);
/* ----- Tastatur-Interrupt belegen ----------------------------------- */
KeyboardInt=SetupJanusSig(JSERV_ENBKB,KeyboardSignal,16,MEMF_PARAMETER|MEM_BYTEACCESS);
if(KeyboardInt==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Janus-Interrupt ist belegt");
}
atstatus=KeyboardInt->ss_ParamPtr;
/* ----- Speicher belegen --------------------------------------------- */
SystemTime=AllocMem(MEMSIZE,MEMF_CLEAR|MEMF_PUBLIC);
Chip=AllocMem(16,MEMF_CLEAR|MEMF_PUBLIC|MEMF_CHIP);
if((SystemTime==NULL)||(Chip==NULL))
{
Fehlerbehandlung(TRUE,"ATKeyboard - Nicht genug Speicher");
}
PublicTime=((ULONG)SystemTime+(ULONG)sizeof(struct SystemTime));
Buffer=((ULONG)PublicTime+(ULONG)sizeof(struct SystemTime));
Message1=((ULONG)Buffer+100L);
Message2=((ULONG)Message1+(ULONG)sizeof(struct Message));
EMessage=((ULONG)Message2+(ULONG)sizeof(struct Message));
SHelp=((ULONG)EMessage+(ULONG)sizeof(struct Message));
ConsoleRequest=((ULONG)SHelp+(ULONG)sizeof(struct SHelp));
Message1->mn_Length=sizeof(struct Message);
Message2->mn_Length=sizeof(struct Message);
EMessage->mn_Length=sizeof(struct Message);
Message1->mn_Node.ln_Type=NT_MESSAGE;
Message2->mn_Node.ln_Type=NT_MESSAGE;
EMessage->mn_Node.ln_Type=NT_MESSAGE;
Message1->mn_ReplyPort=Port3;
Message2->mn_ReplyPort=Port3;
MouseImage.ImageData=Chip;
/* ----- Console-Device öffnen ---------------------------------------- */
ConsoleDev=OpenDevice("console.device",-1L,ConsoleRequest,0);
if(ConsoleDev!=0)
{
Fehlerbehandlung("ATKeyboard - Console-Device nicht ladbar");
}
ConsoleDevice=ConsoleRequest->io_Device;
/* ----- TimerTask erstellen ------------------------------------------ */
bool=ErstelleTimerTask();
if(bool==FALSE)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Fehler bei Task-Erstellung");
}
/* ----- ARexx installieren ------------------------------------------- */
RexxSysBase=OpenLibrary("rexxsyslib.library",0L);
if(RexxSysBase!=NULL)
{
ARexxPort=FindPort(ARexxName);
if(ARexxPort==NULL)
{
ARexxPort=CreatePort(ARexxName,0);
if(ARexxPort==NULL)
{
Fehlerbehandlung(TRUE,"ATKeyboard - Fehler beim ARexx-Port");
}
Prefs=AllocMem(sizeof(struct Einstellungen),MEMF_CLEAR|MEMF_PUBLIC);
if(Prefs==NULL) Fehlerbehandlung(TRUE,"ATKeyboard - Kein Speicher für ARexx");
ARexx=TRUE;
ARexxSignal=ARexxPort->mp_SigBit;
ARexxSignalMask=(1L<<ARexxSignal);
WaitSignalMask+=ARexxSignalMask;
}
else
{
Requester("Information:","ARexx-Port existiert schon.","Okay",NULL);
ARexxPort=NULL;
}
}
if(ARexxPort==NULL)
{
if(KickstartVersion>=36)
{
SetWindowTitles(WindowPtr,"ACHTUNG: ARexx ist nicht möglich.",TitelText);
Delay(50);
}
}
/* ----- Clipboard installieren --------------------------------------- */
ClipPort=CreatePort("ATKeyboard Clipboard Device Transfer Port",0L);
if(ClipPort!=NULL)
{
ClipReq=CreateExtIO(ClipPort,sizeof(struct IOClipReq));
if(ClipReq!=NULL)
{
ClipDev=OpenDevice("clipboard.device",0,ClipReq,0);
}
}
if(ClipDev!=0)
{
SetWindowTitles(WindowPtr,"ACHTUNG: Clipboard nicht verfügbar.",TitelText);
Clipboard_Item.Flags &= xITEMENABLED;
Delay(50);
}
/* ----- Narrator installieren ---------------------------------------- */
bool=InitNarrator();
if(bool==FALSE)
{
SetWindowTitles(WindowPtr,"ACHTUNG: Narrator nicht verfügbar.",TitelText);
Delay(50);
Speak_Item.Flags &= xITEMENABLED;
Speak=FALSE;
}
/* ----- Installation beenden ----------------------------------------- */
Online=TRUE;
SystemOK=TRUE;
KontrolliereService();
KontrolliereLPT1();
KontrolliereUhr();
KontrolliereSchoner();
app=CreateAppItem(AppName);
if(app!=NULL)
{
AppSignalMask=app->SignalMask;
WaitSignalMask+=AppSignalMask;
} else AppSignalMask=0;
if(Einstellungen.HiFiPlayerAutoStart)
{
HiFiTime=1;
if(Einstellungen.HiFiPlayerWaitActive) HiFiTime=Einstellungen.HiFiPlayerWait;
}
RegCheck();
SetMenuStrip(WindowPtr,&Menu1);
LeereIDCMP(WindowPtr);
Say("welcome to a t keyboard");
SetWindowTitles(WindowPtr,OnlineText,TitelText);
}
/* Programm beenden */
VOID CloseAll()
{
if(RegWindow) DeleteStdWindow(RegWindow);
if(app) DeleteAppItem(app);
if(SysTestWindow) Close(SysTestWindow);
if(Schoner)
{
Schoner=FALSE;
KontrolliereSchoner();
}
if(LPT1)
{
LPT1=FALSE;
KontrolliereLPT1();
}
if(WindowPtr)
{
ClearMenuStrip(WindowPtr);
CloseWindow(WindowPtr);
}
if(SubTask)
{
PutMsg(Port4,Message1);
WaitPort(Port3);
GetMsg(Port3);
}
if(SystemOK==TRUE)
{
if(Einstellungen.SichernBeiEnde) SichereEinstellungen();
}
if(ConsoleDev==0) CloseDevice(ConsoleRequest);
if(ClipDev==0) CloseDevice(ClipReq);
if(TimeService) DeleteService(TimeService);
if(FRTags) FreeTagItems(FRTags);
if(FileRequester) FreeFileRequest(FileRequester);
if(KeyboardInt) CleanupJanusSig(KeyboardInt);
if(ServiceSignal!=-1) FreeSignal(ServiceSignal);
if(TimerTaskSignal!=-1) FreeSignal(TimerTaskSignal);
if(KeyboardSignal!=-1) FreeSignal(KeyboardSignal);
if(SchonerFont) CloseFont(SchonerFont);
if(SystemTime) FreeMem(SystemTime,MEMSIZE);
if(Chip) FreeMem(Chip,16);
if(KeyCodes) FreeMem(KeyCodes,sizeof(struct KeyCodes));
if(Prefs!=NULL) FreeMem(Prefs,sizeof(struct Einstellungen));
if(Port1) DeletePort(Port1);
if(Port2) DeletePort(Port2);
if(Port3) DeletePort(Port3);
if(Port4) DeletePort(Port4);
if(Port5) DeletePort(Port5);
if(ClipReq) DeleteExtIO(ClipReq);
if(ClipPort) DeletePort(ClipPort);
if(ParallelRequest) DeleteExtIO(ParallelRequest);
if(ParallelPort) DeletePort(ParallelPort);
if(ARexxPort) DeletePort(ARexxPort);
RemoveNarrator();
if(NIL) Close(NIL);
if(UtilityBase) CloseLibrary(UtilityBase);
if(AslBase) CloseLibrary(AslBase);
if(RexxSysBase) CloseLibrary(RexxSysBase);
if(MathTransBase) CloseLibrary(MathTransBase);
if(MathBase) CloseLibrary(MathBase);
if(JanusBase) CloseLibrary(JanusBase);
if(IconBase) CloseLibrary(IconBase);
if(DiskfontBase) CloseLibrary(DiskfontBase);
if(ExpansionBase) CloseLibrary(ExpansionBase);
if(TranslatorBase) CloseLibrary(TranslatorBase);
if(ATUtilitiesBase)
{
if(Erweiterungen_Item.SubItem) DeleteUtilityList();
CloseLibrary(ATUtilitiesBase);
}
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(GfxBase) CloseLibrary(GfxBase);
exit(0);
}
/* ASCII-Daten an PC übertragen */
VOID Uebertragen()
{
BOOL bool;
REGISTER UBYTE *name;
REGISTER UBYTE *Titel;
register struct FileHandle *fh;
if(Online==FALSE)
{
bool=Requester("Zum Übertragen muß ATKeyboard",
"auf \"Online\" gesetzt sein.",
"Gehe auf Online","Abbruch");
if(bool==FALSE) return;
XLine(TRUE);
}
bool=TRUE;
do
{
if(FileRequester!=NULL)
{
name=FileReq("Datei an PC Übertragen","~(#?.info)");
}
else
{
name=StringAbfrage(TRUE,"Name der zu Übertragenden Datei:","");
}
if(name!=NULL)
{
fh=Open(name,MODE_OLDFILE);
if(fh!=NULL)
{
Titel=WindowPtr->Title;
SendeDatei(fh);
SetWindowTitles(WindowPtr,Titel,TitelText);
bool=FALSE;
}
else
{
bool=Requester("Die angegebene Datei konnte",
"nicht geöffnet werden.","Nochmal","Abbruch");
}
}
else
{
bool=FALSE;
}
}
while(bool==TRUE);
}
/* Clip übertragen */
VOID UebertrageClip()
{
BOOL bool;
REGISTER UBYTE *name;
REGISTER UBYTE *Titel;
register struct FileHandle *fh;
if(Online==FALSE)
{
bool=Requester("Zum Übertragen muß ATKeyboard",
"auf \"Online\" gesetzt sein.",
"Gehe auf Online","Abbruch");
if(bool==FALSE) return;
XLine(TRUE);
}
SendeClip();
}
/* Utility-Manager aufrufen */
VOID Manager()
{
REGISTER BOOL okay;
okay=Execute(ManagerName,NULL,NIL);
if(okay==FALSE)
{
InfoRequest("Utility-Manager konnte nicht gestartet werden.");
}
}
/* Amiga und F-Taste gedrückt */
VOID FTaste(num,qualifier)
UBYTE num;
UWORD qualifier;
{
UBYTE *code;
REGISTER UBYTE typ,i;
typ=0;
if((qualifier & IEQUALIFIER_RSHIFT)||(qualifier & IEQUALIFIER_LSHIFT)) typ=1;
if(qualifier & IEQUALIFIER_CONTROL) typ+=2;
switch(typ)
{
case 1:
code=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].FTasten.FTastenShift[num];
break;
case 2:
code=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].FTasten.FTastenCtrl[num];
break;
case 3:
code=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].FTasten.FTastenShiftCtrl[num];
break;
default:
code=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].FTasten.FTasten[num];
break;
}
if(code[0]!=0)
{
for(i=1;i<code[0];i++) Taste(code[i],0);
}
}
/* Fehlerbehandlung */
VOID Fehlerbehandlung(menue,text)
BOOL menue;
UBYTE *text;
{
REGISTER ULONG Class=LONELYMESSAGE;
REGISTER BOOL ende=FALSE;
REGISTER WORD ItemNum,MenuNum,SubItemNum,Code;
register struct IntuiMessage *IMessage;
if(menue==TRUE)
{
ClearMenuStrip(WindowPtr);
Menu2.Flags &= xMENUENABLED;
Menu3.Flags &= xMENUENABLED;
Menu4.Flags &= xMENUENABLED;
Menu5.Flags &= xMENUENABLED;
if(JanusBase==NULL) Menu6.Flags &= xMENUENABLED;
if(ATUtilitiesBase==NULL)
{
Information_Item.Flags &= xITEMENABLED;
Manager_Item.Flags &= xITEMENABLED;
Menu7.Flags &= xMENUENABLED;
Menu8.Flags &= xMENUENABLED;
}
EinstellungenSichern_Item.Flags &= xITEMENABLED;
EinstellungenLaden_Item.Flags &= xITEMENABLED;
Erweiterungen_Item.Flags &= xITEMENABLED;
EinstellungenAendern1_Item.Flags &= xITEMENABLED;
EinstellungenAendern2_Item.Flags &= xITEMENABLED;
Manager_Item.Flags &= xITEMENABLED;
Uebertragen_Item.Flags &= xITEMENABLED;
SetMenuStrip(WindowPtr,&Menu1);
}
SetWindowTitles(WindowPtr,text,TitelText);
while(ende==FALSE)
{
WaitPort(WindowPtr->UserPort);
IMessage=GetMsg(WindowPtr->UserPort);
Class=IMessage->Class;
Code=IMessage->Code;
ReplyMsg(IMessage);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case MENUPICK:
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
SubItemNum=SUBNUM(Code);
switch(MenuNum)
{
case MENU_DATEI:
switch(ItemNum)
{
case ITEM_ENDE:
ende=TRUE;
break;
case ITEM_INFORMATION:
ShowInformation();
break;
case ITEM_MANAGER:
Manager();
break;
}
break;
case MENU_ATPREFS:
ATPrefs(ItemNum,SubItemNum);
break;
case MENU_HILFE:
Hilfe(ItemNum);
break;
case MENU_HIFI:
HiFi(ItemNum,SubItemNum);
break;
}
break;
}
}
CloseAll();
}
/* Requester erzeugen */
BOOL Requester(t1,t2,positiv,negativ)
UBYTE *t1,*t2,*positiv,*negativ;
{
REGISTER BOOL bool;
REGISTER UBYTE *Titel;
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,"ATKeyboard - Requester",TitelText);
ClearMenuStrip(WindowPtr);
bool=MultiRequest(t1,t2,positiv,negativ);
SetMenuStrip(WindowPtr,&Menu1);
SetWindowTitles(WindowPtr,Titel,TitelText);
return(bool);
}
/* ASL-Filerequester */
UBYTE *FileReq(titel,pattern)
UBYTE *titel;
UBYTE *pattern;
{
REGISTER UBYTE *file;
FRTags[0].ti_Data=(ULONG)pattern;
FRTags[2].ti_Data=titel;
file=NULL;
strcpy(&FileBuffer,"");
if(AslRequest(FileRequester,FRTags))
{
strcpy(&FileBuffer,FileRequester->rf_Dir);
if((strlen(&FileBuffer))==0)
{
strcpy(&FileBuffer,FileRequester->rf_File);
}
else
{
switch(FileBuffer[strlen(&FileBuffer)-1])
{
case ' ':
case ':':
break;
default:
strcat(&FileBuffer,"/");
break;
}
strcat(&FileBuffer,FileRequester->rf_File);
}
file=&FileBuffer;
}
return(file);
}
/* PC-Reset */
#asm
public _ResetPC
_ResetPC:
movem.l a0-a1/a6/d0-d2,-(sp)
move.l _JanusBase,a6
jsr -102(a6)
moveq #0,d1
movea.l d0,a0
adda.l #524285,a0
move.b (a0),d1
andi.l #251,d1
move.b d1,(a0)
moveq #0,d2
movea.l d0,a1
adda.l #524277,a1
move.b (a1),d2
move.l #254,d1
move.b d1,(a0)
movem.l (sp)+,a0-a1/a6/d0-d2
rts
#endasm
/* Tastentabelle setzen */
VOID SetzeTM(num)
UWORD num;
{
REGISTER WORD i;
if(KeyCodes->KeyTab[num].Valid)
{
for(i=0;i<256;i++)
{
TastenTabelle[i]=KeyCodes->KeyTab[num].Keys[i];
}
}
else
{
for(i=0;i<256;i++)
{
TastenTabelle[i]=KeyCodes->KeyTab[0].Keys[i];
}
Aktiv(&TM_Item[0]);
for(i=1;i<=7;i++) Inaktiv(&TM_Item[i]);
}
Einstellungen.Tastaturmodus=num;
}
/* Hilfe-System aufrufen */
VOID Hilfe(num)
UWORD num;
{
switch(num)
{
case ITEM_HINDEX:
Say("loading the online help's index");
Help(HelpName,0);
break;
case ITEM_HDATEI:
Help(HelpName,100);
break;
case ITEM_HTASTATUR:
Help(HelpName,140);
break;
case ITEM_HBEFEHLE:
Help(HelpName,160);
break;
case ITEM_HSCHONER:
Help(HelpName,170);
break;
case ITEM_HLPT1:
Help(HelpName,180);
break;
case ITEM_HATPREFS:
Help(HelpName,190);
break;
case ITEM_HHIFI:
Help(HelpName,198);
break;
case ITEM_HHILFE:
Help(HelpName,210);
break;
case ITEM_AREXX:
Help(HelpName,310);
break;
case ITEM_FEHLER:
Help(HelpName,320);
break;
}
}
/* Registrierungsinformation */
VOID RegCheck()
{
UBYTE str[60];
REGISTER BOOL bool;
REGISTER UWORD i,j;
register struct FileHandle *fh;
register struct RastPort *rp;
RegWindow=CreateStdWindow(NULL,75,110+BorderHeight(),450,42,0L,0L);
if(RegWindow!=NULL)
{
rp=RegWindow->RPort;
SetFont(rp,OpalFont);
SelectStdFPen(rp);
#ifndef DEMO
WriteText(rp,15,10,"ATKeyboard - Programminformation");
WriteText(rp,15,23,"Sie benutzen die Vollversion von ATKeyboard,");
sprintf(&str,"Version %ld.%ld vom %ld. %s %ld.",ATKeyboardVersion,
ATKeyboardRevision,
ATKeyboardTag,
ATKeyboardMonat,
ATKeyboardJahr);
WriteText(rp,15,33,&str);
RegTime=7;
#else
WriteText(rp,15,23,"Dies ist eine eingeschränkte");
WriteText(rp,15,33,"DEMO-VERSION von ATKeyboard!!!");
RegTime=-1;
#endif
}
}
/* HiFi-Player-Fernsteuerung */
VOID HiFi(num,sub)
UWORD num,sub;
{
UBYTE str[50];
REGISTER UBYTE x;
REGISTER BOOL bool;
x=Einstellungen.HiFiPlayerNum;
if(x>0)
sprintf(&str,"ATAudio%ld:",x);
bool=TRUE;
switch(num)
{
case 7466:
Say("starting audio player");
if(x==0) UtilityQuiet(HiFiPort,1100); else EP(&str,"autostart");
break;
case ITEM_PLAY:
Say("start playing");
if(x==0) bool=UtilityQuiet(HiFiPort,1001); else EP(&str,"play");
break;
case ITEM_STOP:
Say("stop playing");
if(x==0) bool=UtilityQuiet(HiFiPort,1002); else EP(&str,"stop");
break;
case ITEM_JUMP:
switch(sub)
{
case SUBITEM_TFIRST:
Say("playing the first song");
if(x==0) bool=UtilityQuiet(HiFiPort,1003); else EP(&str,"first");
break;
case SUBITEM_TLAST:
Say("playing the last song");
if(x==0) bool=UtilityQuiet(HiFiPort,1004); else EP(&str,"last");
break;
case SUBITEM_TNEXT:
Say("playing the next song");
if(x==0) bool=UtilityQuiet(HiFiPort,1005); else EP(&str,"next");
break;
case SUBITEM_TPREV:
Say("playing the previous song");
if(x==0) bool=UtilityQuiet(HiFiPort,1006); else EP(&str,"prev");
break;
case SUBITEM_TRND:
Say("playing a song chosen by random numbers");
if(x==0) bool=UtilityQuiet(HiFiPort,1500); else EP(&str,"rnd");
break;
}
break;
case ITEM_KBEARBEITEN:
if(x==0) bool=UtilityQuiet(HiFiPort,1007); else EP(&str,"edit");
break;
case ITEM_KLADEN:
if(x==0) bool=UtilityQuiet(HiFiPort,1008); else EP(&str,"load");
break;
case ITEM_KSICHERN:
if(x==0) bool=UtilityQuiet(HiFiPort,1009); else EP(&str,"save");
break;
case ITEM_AUAENDERN:
if(x==0) bool=UtilityQuiet(HiFiPort,1010); else EP(&str,"prefs");
break;
case ITEM_PLAENDERN:
Auswahl();
break;
case ITEM_HIFICTRL:
if(x==0)
bool=UtilityQuiet(HiFiPort,1012);
else
EP(&str,"display");
Delay(50);
ActivateWindow(WindowPtr);
break;
case ITEM_LAUTER:
Say("increasing the volume");
if(x==0) bool=UtilityQuiet(HiFiPort,1013); else EP(&str,"vol+");
break;
case ITEM_LEISER:
Say("decreasing the volume");
if(x==0) bool=UtilityQuiet(HiFiPort,1014); else EP(&str,"vol-");
break;
case ITEM_HIFIENDE:
Say("removing the audio player");
if(x==0) bool=UtilityQuiet(HiFiPort,UTILITY_QUIT); else EP(&str,"quit");
break;
default:
bool=TRUE;
break;
}
if(bool==FALSE) DisplayBeep(NULL);
}
/* Kommandos an externe Player geben */
VOID EP(dir,cmd)
UBYTE *dir,*cmd;
{
UBYTE str[80];
if(Einstellungen.HiFiPlayerARexx==NO)
strcpy(&str,"Run Execute ");
else
strcpy(&str,"Run SYS:REXXC/RX ");
strcat(&str,dir);
strcat(&str,cmd);
if(Einstellungen.HiFiPlayerARexx)
strcat(&str,".rexx");
Execute(&str,NULL,NIL);
}
/* HiFi-Player Auswahl */
UBYTE *PlayerNames[]={"ATUtilities HiFi-Player",
"Externer Player 1",
"Externer Player 2",
"Externer Player 3",
"Externer Player 4",
"Externer Player 5"};
VOID Auswahl()
{
UBYTE *vz,*Titel;
UBYTE str[8];
REGISTER BOOL ende;
REGISTER ULONG Class;
register struct Gadget *gad,*autos,*verz,*rxx;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
ClearMenuStrip(WindowPtr);
Titel=WindowPtr->Title;
SetWindowTitles(WindowPtr,TitelText,TitelText);
win=CreateStdWindow("Audio - Auswahl des externen Players",75,75,450,108,
CLOSEWINDOW|GADGETUP,
ACTIVATE|WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,GetOpalFont());
CreateBoolGadget(win,15,15,25,12,"»",1);
DrawNTextBorder(win,45,15,390,12,PlayerNames[Einstellungen.HiFiPlayerNum]);
if(Einstellungen.HiFiPlayerAutoStart!=0)
autos=CreateSToggleGadget(win,15,58,420,12,"Auto-Start durch ATKeyboard",20);
else
autos=CreateNToggleGadget(win,15,58,420,12,"Auto-Start durch ATKeyboard",20);
if(Einstellungen.HiFiPlayerWaitActive!=0)
verz=CreateSToggleGadget(win,15,73,420,12,"Verzögerung des Auto-Starts",30);
else
verz=CreateNToggleGadget(win,15,73,420,12,"Verzögerung des Auto-Starts",30);
if(Einstellungen.HiFiPlayerARexx!=0)
rxx=CreateSToggleGadget(win,15,40,420,12,"Befehlsskripte als ARexx-Befehl aufrufen",30);
else
rxx=CreateNToggleGadget(win,15,40,420,12,"Befehlsskripte als ARexx-Befehl aufrufen",30);
sprintf(&str,"%ld",Einstellungen.HiFiPlayerWait);
vz=CreateIntegerGadget(win,385,88,50,12,&str,5,10);
SelectStdFPen(rp);
WriteText(rp,25,96,"Verzögerung in Sekunden:");
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
Einstellungen.HiFiPlayerNum+=1;
if(Einstellungen.HiFiPlayerNum>5) Einstellungen.HiFiPlayerNum=0;
DrawCNTextBorder(win,45,15,390,12,PlayerNames[Einstellungen.HiFiPlayerNum]);
break;
}
break;
}
}
if(autos->Flags & SELECTED) Einstellungen.HiFiPlayerAutoStart=1; else Einstellungen.HiFiPlayerAutoStart=0;
if(verz->Flags & SELECTED) Einstellungen.HiFiPlayerWaitActive=1; else Einstellungen.HiFiPlayerWaitActive=0;
if(rxx->Flags & SELECTED) Einstellungen.HiFiPlayerARexx=1; else Einstellungen.HiFiPlayerARexx=0;
Einstellungen.HiFiPlayerWait=atol(vz);
DeleteStdWindow(win);
}
SetWindowTitles(WindowPtr,Titel,TitelText);
SetMenuStrip(WindowPtr,&Menu1);
}